home *** CD-ROM | disk | FTP | other *** search
- Path: gail.ripco.com!mambuhl
- From: mambuhl@ripco.com (Martin Ambuhl)
- Newsgroups: comp.lang.c
- Subject: Re: string and NULL :ques
- Date: 17 Feb 1996 21:00:31 GMT
- Organization: Ripco Communications, Inc.
- Message-ID: <4g5flf$bil@gail.ripco.com>
- NNTP-Posting-Host: foley.ripco.com
-
- zakrzews@pegasus.montclair.edu (Tomas Zakrzewski)
- in <zakrzews.824018783@pegasus.montclair.edu> asks:
-
- >Is it save to use a string library and stdio library with strings that are
- >no terminated by NULL charater. If is not, which function may not work correctl
- >and what would happen with non termianded string if a function is applied to
- >that string.
-
- From the standard (ISO 7.1.1):
- "A string is a contiguous sequence of characters terminated by and
- including the first null character."
-
- So your question makes no sense: there is no such thing as a string not
- terminated by a null character. And it is `null'; `NULL' is a null
- pointer, not a null character.
-
- If you want to work on a char array which does not contain a null
- character, how do you propose to tell the library functions where it
- ends?
-
- One possible result of using the library functions on such a char array
- is a segfault. On M$BrokenOS, the results are completely unpredictable,
- since there is no protection against access (including writing) of
- regions containing other data, your program, or even portions of the OS.
-
- --
- * Martin Ambuhl net: mambuhl@ripco.com
- * Chicago, IL (USA)
-